package com.netease.pris.activity.view;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.netease.imageex.ImageViewTouch;
import com.netease.pris.activity.PRISActivitySetting;
import com.netease.pris.c.a;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class AdBar
{
  private final long a = 120000L;
  private int b = 0;
  private int c = 0;
  private final FrameLayout d;
  private final Context e;
  private final n f;
  private final Handler g = new Handler(Looper.getMainLooper());
  private List h;
  private AdBar.AdBroadcast i;
  private ImageView j;
  private FrameLayout k;

  public AdBar(Context paramContext, FrameLayout paramFrameLayout)
  {
    this.e = paramContext;
    this.d = paramFrameLayout;
    this.f = new n(this.e, this.d, null);
    e();
    d();
  }

  private Bitmap a(Uri paramUri)
  {
    return BitmapFactory.decodeFile(paramUri.getPath());
  }

  private void a(int paramInt1, int paramInt2)
  {
    int m = 0;
    if (this.h.size() > 0)
    {
      paramInt1 %= this.h.size();
      if (((List)this.h.get(paramInt1)).size() > 0)
        paramInt2 %= ((List)this.h.get(paramInt1)).size();
    }
    t localt = (t)((List)this.h.get(paramInt1)).get(paramInt2);
    Uri localUri = localt.a;
    if (localUri == null)
    {
      int i3 = ((List)this.h.get(paramInt1)).size();
      if (i3 > 0)
      {
        paramInt2++;
        if (paramInt2 > i3)
        {
          paramInt1 = (paramInt1 + 1) % this.h.size();
          paramInt2 = 0;
        }
      }
      this.b = paramInt1;
      this.c = paramInt2;
      this.g.postDelayed(new bx(this, paramInt1, paramInt2), localt.b);
    }
    while (true)
    {
      return;
      try
      {
        Bitmap localBitmap = a(localUri);
        if (localBitmap == null)
        {
          int i2 = ((List)this.h.get(paramInt1)).size();
          if (i2 > 0)
          {
            paramInt2++;
            if (paramInt2 > i2)
            {
              paramInt1 = (paramInt1 + 1) % this.h.size();
              this.b = paramInt1;
              this.c = m;
              this.g.postDelayed(new bx(this, paramInt1, m), localt.b);
              continue;
            }
          }
        }
        else
        {
          ViewGroup localViewGroup = (ViewGroup)LayoutInflater.from(this.e).inflate(2130903044, null);
          localViewGroup.setVisibility(4);
          ((ImageViewTouch)localViewGroup.findViewById(2131558418)).a(localBitmap, true, true);
          this.k.addView(localViewGroup, 0);
          this.f.a(localViewGroup);
          int i1 = ((List)this.h.get(paramInt1)).size();
          if (i1 > 0)
          {
            paramInt2++;
            if (paramInt2 > i1)
            {
              paramInt1 = (paramInt1 + 1) % this.h.size();
              this.b = paramInt1;
              this.c = m;
              this.g.postDelayed(new bx(this, paramInt1, m), localt.b);
              continue;
            }
          }
        }
      }
      finally
      {
        while (true)
        {
          int n = ((List)this.h.get(paramInt1)).size();
          if (n > 0)
          {
            paramInt2++;
            if (paramInt2 > n)
              paramInt1 = (paramInt1 + 1) % this.h.size();
          }
          while (true)
          {
            this.b = paramInt1;
            this.c = m;
            this.g.postDelayed(new bx(this, paramInt1, m), localt.b);
            throw localObject;
            m = paramInt2;
          }
          m = paramInt2;
          continue;
          m = paramInt2;
        }
      }
    }
  }

  private void a(long paramLong)
  {
    a(new ax(this), paramLong);
  }

  private void d()
  {
    long l1 = PRISActivitySetting.n(this.e);
    long l2 = System.currentTimeMillis() - l1;
    if (l2 >= 120000L)
      f();
    while (true)
    {
      return;
      a(120000L - l2);
    }
  }

  private void e()
  {
    this.j.setOnClickListener(new az(this));
  }

  private void f()
  {
    if (b() > 0)
    {
      SharedPreferences localSharedPreferences = this.e.getSharedPreferences("ad_pref", 0);
      a(localSharedPreferences.getInt("key_curpos", 0), localSharedPreferences.getInt("key_curindex", 0));
      this.d.setVisibility(0);
    }
    while (true)
    {
      return;
      this.d.setVisibility(8);
    }
  }

  public void a()
  {
    if (this.g != null)
      this.g.removeCallbacksAndMessages(null);
    if (this.i != null)
    {
      this.i.a();
      this.i = null;
    }
    if (this.k != null)
    {
      this.k.removeAllViews();
      this.k.clearAnimation();
      this.k = null;
    }
    if (this.d != null)
    {
      this.d.removeAllViews();
      this.d.clearAnimation();
    }
    if (this.h != null)
    {
      Iterator localIterator = this.h.iterator();
      while (localIterator.hasNext())
        ((List)localIterator.next()).clear();
      this.h.clear();
      this.h = null;
    }
    if (this.j != null)
    {
      this.j.clearAnimation();
      this.j = null;
    }
  }

  public void a(bg parambg, long paramLong)
  {
    if (this.i == null)
      this.i = new AdBar.AdBroadcast(this.e);
    this.i.a(parambg, paramLong);
  }

  public int b()
  {
    if (this.h == null)
      this.h = new ArrayList();
    this.h.clear();
    for (int m = 0; m < 10; m++)
    {
      File localFile = new File(a.a());
      if (!localFile.exists())
        continue;
      File[] arrayOfFile = localFile.listFiles();
      if ((arrayOfFile == null) || (arrayOfFile.length <= 0))
        continue;
      ArrayList localArrayList = new ArrayList();
      localArrayList.clear();
      int n = arrayOfFile.length;
      for (int i1 = 0; i1 < n; i1++)
      {
        t localt = new t();
        localt.a = Uri.fromFile(arrayOfFile[i1]);
        localt.b = (2000 * (i1 + 1) + m * 500);
        localArrayList.add(localt);
      }
      this.h.add(localArrayList);
    }
    return this.h.size();
  }

  /** @deprecated */
  public void c()
  {
    monitorenter;
    try
    {
      if (this.i != null)
        this.i.a();
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.activity.view.AdBar
 * JD-Core Version:    0.6.0
 */